﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace TB_WS.Class
{
    public class QianNiu
    {
        public static int get_QN_Nick_Count(string TB_Nick)
        {
            string sql = "select count(*) from QN_Info where TB_Seller_Nick='" + TB_Nick + "'";
            return Convert.ToInt32(Unit.db_Conn.scalar(sql));
        }

        public static int Insert_QN_Info(string TB_Nick,string AccessToken,Int64 Top_expires)
        {
            string sql = "insert into QN_Info values('" + TB_Nick + "','" + AccessToken + "'," + Top_expires + ",'available')";
            return Unit.db_Conn.Nonquery(sql);
        }

        public static int Update_QN_Access_Token(string TB_Nick, string AccessToken, Int64 Top_expires)
        {
            string sql = "update QN_Info set AccessToken='" + AccessToken + "', Top_expires=" + Top_expires + " where TB_Seller_Nick='" + TB_Nick + "'";
            return Unit.db_Conn.Nonquery(sql);
        }

        public static DataSet Get_QN_Info(string TB_Nick)
        {
            string sql = "select * from QN_Info where TB_Seller_Nick='" + TB_Nick + "'";
            return Unit.db_Conn.select(sql);
        }
    }
}